﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TFMAPI;

namespace TwitterFollowersMonitor
{
    public partial class TwitterUserInfoCtl : UserControl
    {
        public TwitterUserInfoCtl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Method for initializing the control with the info from one specific Twitter user
        /// </summary>
        /// <param name="tui"></param>
        public void DisplayUserInfo(TwitterUserInfo tui)
        {
            //Fill the UI from the info stored in the TwitterUserInfo parameter
            lblUserName.Text = String.Format("{0} ({1})", tui.name, tui.screen_name);
            imgUser.ImageLocation = tui.profile_image_url_full;
            lblFollowers.Text = string.Format("{0:N0} Followers", tui.followers_count);
            lblFriends.Text = string.Format("{0:N0} Following", tui.friends_count);
            lblUpdates.Text = string.Format("{0:N0} Tweets", tui.statuses_count);
            if (tui.status != null)
                lblStatus.Text = string.Format("Last update: {0} (at {1})", tui.status.text, tui.status.createdAt);
            else
                lblStatus.Text = "No status";
            lblLocation.Text = tui.location;
            lblJoined.Text = tui.createdAt.ToLongDateString();
            lblBio.Text = tui.description;
            lnkUserUrl.Text = tui.url;
            lnkTwitter.Text = string.Format("http://twitter.com/{0}", tui.screen_name);
        }

        private void lnkUserUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LinkLabel lnk = (LinkLabel) sender;
            System.Diagnostics.Process.Start(lnk.Text);
        }

    }
}
